<%--
  Created by IntelliJ IDEA.
  User: hongfive
  Date: 2019/1/7
  Time: 20:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basepath = request.getScheme()
            + "://" + request.getServerName()
            + ":" + request.getServerPort() + "/" + path;
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>新增分类</title>
    <link rel="stylesheet" href="<%=basepath%>/statics/backcss/css/add.css">
    <link rel="stylesheet" href="<%=basepath%>/statics/backcss/css/bootstrap.min.css">
    <script src="<%=basepath%>/statics/backcss/js/jquery.min.js"></script>

    <script>
        //获取地址栏中的键值对
        function getUrlPara(paraName){
            var sUrl = location.href;
            var sReg = "(?:\\?|&){1}"+paraName+"=([^&]*)"
            var re=new RegExp(sReg,"gi");
            re.exec(sUrl);
            return RegExp.$1;
        }
       function addmsg() {
           var cid=getUrlPara("cid");
           var message = new Object();
           message.cid=cid;
           message.msgcontent=$("#msgcontent").val();
           var messageData = JSON.stringify(message);
           console.log(message);
           $.ajax({

               type:"Post",
               url:"../message/addmsg",
               async:false,
               data:messageData,
               contentType:'application/json;charset=utf-8',
               success:function (data) {
                   console.log(data);
                   var json=data;
                   if (json.code==0){
                       alter(json.message);
                   }
                   else {
                       alter(json.message);
                   }
               }
           })
       }
    </script>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">
                留言板
            </a>
        </div>
    </div>
</nav>
<div class="container">
    <div class="jumbotron">
        <h1>Hello!</h1>
        <p>~写下你的留言~</p>
    </div>
    <div class="page-header">
        <h3><small>编辑</small></h3>
    </div>
    <form class="form-horizontal" action="../canvas/listdo" method="post">
        <div class="form-group">
            <label for="msgcontent" class="col-sm-2 control-label">名称 ：</label>
            <div class="col-sm-8">
                <input name="msgcontent" class="form-control" id="msgcontent" value="请输入留言">
            </div>
        </div>
        <%--<div class="form-group">
            <label for="name" class="col-sm-2 control-label">描述 ：</label>
            <div class="col-sm-8">
                <input type="text" name="description" class="form-control" id="description" value="描述一">
            </div>
        </div>--%>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary" onclick="addmsg()">添加</button>&nbsp;&nbsp;&nbsp;
            </div>
        </div>
    </form>
</div>
<footer class="text-center" >
</footer>
</body>
</html>

